from typing import List
from geopandas import GeoDataFrame,GeoSeries
import geopandas as gp
import geojson as gj
from geoalchemy2 import WKBElement,WKTElement
import geoalchemy2 as ga
import shapely.wkt as wkt
import shapely.wkb as wkb
from geoalchemy2.shape import  to_shape,from_shape

def gdf2gj(gdf:GeoDataFrame):
    return gj.FeatureCollection(gj.loads(gdf.to_json()))

def feature2gdf(geojson:List[gj.GeoJSON]):
    return GeoDataFrame.from_features(gj.FeatureCollection(geojson))

def featurecollection2gdf(geojson:gj.GeoJSON):
    return GeoDataFrame.from_features(geojson)

def geoa2wkt(element):
    try:
        return gj.dumps(to_shape(element))
    except:
        raise Exception